package server;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import protocol.Protocol;

import tokenizer.NewLineTokenizer;
import tokenizer.Tokenizer;

public class Listener {
private ServerSocketChannel serverSocket;
//	private ServerSocket serverSocket;
 private int port;

 
public Listener(int port) 
{
	/*
	this.port = port;
	try {
		serverSocket = ServerSocketChannel.open();
		serverSocket.bind(new InetSocketAddress(port));
	} catch (IOException e) {
	
		e.printStackTrace();
	}*/
	
}
public void Listen(Protocol prot) throws IOException
{
	ExecutorService executor = Executors.newFixedThreadPool(10);
	ServerSocket sock2 = new ServerSocket(6669);
	while(true)
	{
		

			//SocketChannel sock = serverSocket.accept();
			Socket sockk = sock2.accept();
			executor.execute(new SocketThread(sockk,prot));
		
	}
	
}
}
